|
|
|
|
|
|
|
After the bank teller clicks the Done button on the deposit form, frmDeposit, the DepositFunds controller class processes the button click. The actual button-click processing is not as important as the actual rule enforcement, but the following code snippet shows the code in DepositFunds' clickedDoneBtn method: |
|
|
|
|
|
|
|
|
Public Sub clickedDoneBtn()
On Error GoTo clickedDoneBtnErr
'your code goes here...
processDeposit
Unload theForm
Set theForm = Nothing
Exit Sub
clickedDoneBtnErr:
'Call RaiseError (MyUnhandledError, "DepositFunds:clickedDoneBtn
'Method")
theErrorHandler.handleErrors Err
End Sub |
|
|
|
|
|
|
|
|
The clickedDoneBtn method invokes the processDeposit method. This latter method logs the transaction properly and then creates a Deposit object, theDeposit, based on the values entered by the bank teller. These values include AccountID and Amount. It then calls the exceedsLimit method of the CashDepositRecord object, theCashDepositRecord, passing a reference to theDeposit. Note that this call is always made regardless of whether the deposit was a cash deposit or if it even exceeded the limit. This is not a requirement, but a pattern that encapsulates the conditional checking for the deposit in the CashDepositRecord class. That way, if the government decides later that the limit rules for cash deposits need to be more complex (that's the government for you), you can simply go to this class and modify the code in the exceedsLimit method, with no other parts of your application being affected. |
|
|
|
|
|
|
|
|
In the exceedsLimit method of the CashDepositRecord class, the amount of the deposit is checked (assuming it's cash deposit). If the amount exceeds the number 10000, the handleErrors method of the ErrorHandler object, theErrorHandler, is invoked. The transaction object, argTransObject, is passed, along with an enumerated constant, eBusinessRules.CheckDepositAmount. This Enum value is a message ID letting ErrorHandler know that this is a business rule exception, not a regular error. Finally, the policy violation is brought to the attention of the bank teller, and the teller is shown the form that contains the online Cash Deposit Record form. If you enforce your policies with object interactions similar to the ones just described, the development and ongoing maintenance activities associated with your application will be much easier. |
|
|
|
|
|